package com.zzmcc.common;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;


/**
 * Created by zhuangyw on 15/1/18.
 */
public class PermissionInterceptor implements Interceptor {
    @Override
    public void intercept(ActionInvocation ai) {
        //System.out.println("Before invoking " + ai.getActionKey());
        //ai.getController().getSessionAttr("loginUser");
        String methodName = ai.getMethodName();
        if(methodName=="validateLogin"||methodName=="login"||ai.getController().getSessionAttr("loginUser")!=null){
            ai.invoke();
        }else {
            ai.getController().redirect("/login");

        }
        //System.out.println("After invoking " + ai.getActionKey());
    }
}
